﻿#include "mainwindow.h"

#pragma execution_character_set("utf-8")

dataCenter dataTable;


bool setCenter::is_show_all = false;
int setCenter::current_week = 0;
bool setCenter::is_rem = "";


bool is_first = false;


const char *char_tixing = "\346\217\220\347\244\272";
const char*char_new = "\346\234\254\350\275\257\344\273\266\344\270\215\344\274\232\350\256\260\345\275\225\n\346\202\250\347\232\204\345\255\246\345\217\267\345\257\206\347\240\201";
const char*char_set_succ = "\350\256\276\347\275\256\346\210\220\345\212\237";

const char*char_net_error = "\347\275\221\347\273\234\351\224\231\350\257\257";


const char*char_net_error_center = "\350\257\267\346\243\200\346\237\245\347\275\221\347\273\234\350\256\276\347\275\256\n\n\n\351\203\250\345\210\206\346\211\213\346\234\272\346\265\201\351\207\217\346\227\240\346\263\225\345\257\274\345\205\245\345\277\205\351\241\273\347\224\250WIFI\n\350\277\231\346\230\257\347\224\261\344\272\216\346\234\215\345\212\241\345\231\250\351\231\220\345\210\266";


bool is_kebiao = true;


void  setCenter::load()
{

	QSettings set("kebiao", "set");
	is_show_all = !set.value("1").toBool();
	current_week = set.value("2").toInt();

	is_rem = set.value("paa").toBool();


	if (current_week <= 0)
	{
		saveCurrentDate();
		current_week = 1;
		is_first = true;

		save();
	}


}




void  TableWidget::mouseMoveEvent(QMouseEvent *e)
{

	if (e->localPos().y() - y > 50)
	{
		is_move = true;
	}

	else if (e->localPos().y() - y<-50)
	{

		is_move = true;
	}


	if (e->localPos().y() - y > 100)
	{

		this->verticalScrollBar()->setValue(this->verticalScrollBar()->minimum());

		x = e->localPos().x();
		y = e->localPos().y();

	}
	else if (e->localPos().y() - y < -100)
	{

		this->verticalScrollBar()->setValue(this->verticalScrollBar()->maximum());
		x = e->localPos().x();
		y = e->localPos().y();

	}



}


void  TableWidget::mousePressEvent(QMouseEvent *e)
{
	is_move = false;

	x = e->localPos().x();
	y = e->localPos().y();

}

void TableWidget::mouseReleaseEvent(QMouseEvent *e)
{
	x = e->localPos().x();
	y = e->localPos().y();


	if (!is_move)
	{

		QTableWidget::cellClicked(y / (verticalHeader()->height() / 7) * 2,
			x / (horizontalHeader()->width() / 7)
			);

	}
}


void  TableWidget::setupUi(QMainWindow *MainWindow)
{
	this->setColumnCount(7);
	QTableWidgetItem *__qtablewidgetitem = new QTableWidgetItem();
	this->setHorizontalHeaderItem(0, __qtablewidgetitem);
	QTableWidgetItem *__qtablewidgetitem1 = new QTableWidgetItem();
	this->setHorizontalHeaderItem(1, __qtablewidgetitem1);
	QTableWidgetItem *__qtablewidgetitem2 = new QTableWidgetItem();
	this->setHorizontalHeaderItem(2, __qtablewidgetitem2);
	QTableWidgetItem *__qtablewidgetitem3 = new QTableWidgetItem();
	this->setHorizontalHeaderItem(3, __qtablewidgetitem3);
	QTableWidgetItem *__qtablewidgetitem4 = new QTableWidgetItem();
	this->setHorizontalHeaderItem(4, __qtablewidgetitem4);
	QTableWidgetItem *__qtablewidgetitem5 = new QTableWidgetItem();
	this->setHorizontalHeaderItem(5, __qtablewidgetitem5);
	QTableWidgetItem *__qtablewidgetitem6 = new QTableWidgetItem();
	this->setHorizontalHeaderItem(6, __qtablewidgetitem6);
	if (this->rowCount() < 14)
		this->setRowCount(14);
	QTableWidgetItem *__qtablewidgetitem7 = new QTableWidgetItem();
	this->setVerticalHeaderItem(0, __qtablewidgetitem7);
	QTableWidgetItem *__qtablewidgetitem8 = new QTableWidgetItem();
	this->setVerticalHeaderItem(1, __qtablewidgetitem8);
	QTableWidgetItem *__qtablewidgetitem9 = new QTableWidgetItem();
	this->setVerticalHeaderItem(2, __qtablewidgetitem9);
	QTableWidgetItem *__qtablewidgetitem10 = new QTableWidgetItem();
	this->setVerticalHeaderItem(3, __qtablewidgetitem10);
	QTableWidgetItem *__qtablewidgetitem11 = new QTableWidgetItem();
	this->setVerticalHeaderItem(4, __qtablewidgetitem11);
	QTableWidgetItem *__qtablewidgetitem12 = new QTableWidgetItem();
	this->setVerticalHeaderItem(5, __qtablewidgetitem12);
	QTableWidgetItem *__qtablewidgetitem13 = new QTableWidgetItem();
	this->setVerticalHeaderItem(6, __qtablewidgetitem13);
	QTableWidgetItem *__qtablewidgetitem14 = new QTableWidgetItem();
	this->setVerticalHeaderItem(7, __qtablewidgetitem14);
	QTableWidgetItem *__qtablewidgetitem15 = new QTableWidgetItem();
	this->setVerticalHeaderItem(8, __qtablewidgetitem15);
	QTableWidgetItem *__qtablewidgetitem16 = new QTableWidgetItem();
	this->setVerticalHeaderItem(9, __qtablewidgetitem16);
	QTableWidgetItem *__qtablewidgetitem17 = new QTableWidgetItem();
	this->setVerticalHeaderItem(10, __qtablewidgetitem17);
	QTableWidgetItem *__qtablewidgetitem18 = new QTableWidgetItem();
	this->setVerticalHeaderItem(11, __qtablewidgetitem18);
	QTableWidgetItem *__qtablewidgetitem19 = new QTableWidgetItem();
	this->setVerticalHeaderItem(12, __qtablewidgetitem19);
	QTableWidgetItem *__qtablewidgetitem20 = new QTableWidgetItem();
	this->setVerticalHeaderItem(13, __qtablewidgetitem20);
	this->setObjectName(QStringLiteral("tableWidget"));
	this->setGeometry(QRect(0, 960 - 870, 640, 870));
	PublicFunc::resetGrid(this);

	this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
	this->setAutoScrollMargin(1);

	horizontalHeader()->setStretchLastSection(true); //设置充满表宽度

	horizontalHeader()->setSectionsClickable(false); //设置表头不可点击（默认点击后进行排序）

	verticalHeader()->setSectionsClickable(false); //设置表头不可点击（默认点击后进行排序）
	verticalHeader()->setSectionsClickable(false);





	horizontalHeader()->setStyleSheet("QHeaderView::section{background:silver;}"); //设置表头背景色
	horizontalHeader()->setStyleSheet("QHeaderView::section{font-color:black;}"); //设置表头背景色

	retranslateUi(MainWindow);


	for (int xx = 0; xx < 14; xx += 2)
	{

		for (int i = 0; i < 7; i++)
		{

			setRowHeight(xx, PublicFunc::getFactory() * 150);
			setRowHeight(xx + 1, 0);

		}
	}


	horizontalHeader()->setDefaultSectionSize(88 * PublicFunc::getFactory());


	for (int i = 0; i < 7; i++)
	{

		horizontalHeader()->resizeSection(i, width() / 7.2);

	}



	verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);
	horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);


	QMetaObject::connectSlotsByName(MainWindow);
} // setupUi

void   TableWidget::retranslateUi(QMainWindow *MainWindow)
{
	MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0));

	QTableWidgetItem *___qtablewidgetitem = this->horizontalHeaderItem(0);

	___qtablewidgetitem->setText(QApplication::translate("MainWindow", "\345\221\250\344\270\200", 0));
	QTableWidgetItem *___qtablewidgetitem1 = this->horizontalHeaderItem(1);
	___qtablewidgetitem1->setText(QApplication::translate("MainWindow", "\345\221\250\344\272\214", 0));
	QTableWidgetItem *___qtablewidgetitem2 = this->horizontalHeaderItem(2);
	___qtablewidgetitem2->setText(QApplication::translate("MainWindow", "\345\221\250\344\270\211", 0));
	QTableWidgetItem *___qtablewidgetitem3 = this->horizontalHeaderItem(3);
	___qtablewidgetitem3->setText(QApplication::translate("MainWindow", "\345\221\250\345\233\233", 0));
	QTableWidgetItem *___qtablewidgetitem4 = this->horizontalHeaderItem(4);
	___qtablewidgetitem4->setText(QApplication::translate("MainWindow", "\345\221\250\344\272\224", 0));
	QTableWidgetItem *___qtablewidgetitem5 = this->horizontalHeaderItem(5);
	___qtablewidgetitem5->setText(QApplication::translate("MainWindow", "\345\221\250\345\205\255", 0));
	QTableWidgetItem *___qtablewidgetitem6 = this->horizontalHeaderItem(6);
	___qtablewidgetitem6->setText(QApplication::translate("MainWindow", "\345\221\250\346\227\245", 0));
	QTableWidgetItem *___qtablewidgetitem7 = this->verticalHeaderItem(0);
	___qtablewidgetitem7->setText(QApplication::translate("MainWindow", "1", 0));
	QTableWidgetItem *___qtablewidgetitem8 = this->verticalHeaderItem(1);
	___qtablewidgetitem8->setText(QApplication::translate("MainWindow", "2", 0));
	QTableWidgetItem *___qtablewidgetitem9 = this->verticalHeaderItem(2);
	___qtablewidgetitem9->setText(QApplication::translate("MainWindow", "3", 0));
	QTableWidgetItem *___qtablewidgetitem10 = this->verticalHeaderItem(3);
	___qtablewidgetitem10->setText(QApplication::translate("MainWindow", "4", 0));
	QTableWidgetItem *___qtablewidgetitem11 = this->verticalHeaderItem(4);
	___qtablewidgetitem11->setText(QApplication::translate("MainWindow", "5", 0));
	QTableWidgetItem *___qtablewidgetitem12 = this->verticalHeaderItem(5);
	___qtablewidgetitem12->setText(QApplication::translate("MainWindow", "6", 0));
	QTableWidgetItem *___qtablewidgetitem13 = this->verticalHeaderItem(6);
	___qtablewidgetitem13->setText(QApplication::translate("MainWindow", "7", 0));
	QTableWidgetItem *___qtablewidgetitem14 = this->verticalHeaderItem(7);
	___qtablewidgetitem14->setText(QApplication::translate("MainWindow", "8", 0));
	QTableWidgetItem *___qtablewidgetitem15 = this->verticalHeaderItem(8);
	___qtablewidgetitem15->setText(QApplication::translate("MainWindow", "9", 0));
	QTableWidgetItem *___qtablewidgetitem16 = this->verticalHeaderItem(9);
	___qtablewidgetitem16->setText(QApplication::translate("MainWindow", "10", 0));
	QTableWidgetItem *___qtablewidgetitem17 = this->verticalHeaderItem(10);
	___qtablewidgetitem17->setText(QApplication::translate("MainWindow", "11", 0));
	QTableWidgetItem *___qtablewidgetitem18 = this->verticalHeaderItem(11);
	___qtablewidgetitem18->setText(QApplication::translate("MainWindow", "12", 0));
	QTableWidgetItem *___qtablewidgetitem19 = this->verticalHeaderItem(12);
	___qtablewidgetitem19->setText(QApplication::translate("MainWindow", "13", 0));
	QTableWidgetItem *___qtablewidgetitem20 = this->verticalHeaderItem(13);
	___qtablewidgetitem20->setText(QApplication::translate("MainWindow", "14", 0));
} // retranslateUi








void  ListWidget::mouseMoveEvent(QMouseEvent *e)
{

	if (e->localPos().y() - y > 20 * PublicFunc::getFactory())
	{
		is_move = true;


	}

	else if (e->localPos().y() - y<-20 * PublicFunc::getFactory())
	{


		is_move = true;

	}


	if (e->localPos().y() - y > 50 * PublicFunc::getFactory())
	{

		this->verticalScrollBar()->setValue(this->verticalScrollBar()->minimum());

		x = e->localPos().x();
		y = e->localPos().y();

	}
	else if (e->localPos().y() - y < -50 * PublicFunc::getFactory())
	{

		this->verticalScrollBar()->setValue(this->verticalScrollBar()->maximum());
		x = e->localPos().x();
		y = e->localPos().y();

	}


}


void  ListWidget::mousePressEvent(QMouseEvent *e)
{
	is_move = false;

	x = e->localPos().x();
	y = e->localPos().y();

}

void ListWidget::mouseReleaseEvent(QMouseEvent *e)
{
	x = e->localPos().x();
	y = e->localPos().y();


	if (!is_move)
	{

		setCurrentRow(y / (100 * PublicFunc::getFactory()) + verticalScrollBar()->value());


		detail_widget4* x = new detail_widget4(this, y / (100 * PublicFunc::getFactory()) + verticalScrollBar()->value());

		x->show();


	}
}


ListWidget::ListWidget(QWidget *p) :QListWidget(p)
{

	this->setGeometry(QRect(0, 960 - 870, 640, 870));


	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);//去掉水平滚动条

}




void  setCenter::save()
{
	QSettings set("kebiao", "set");
	set.setValue("1", !is_show_all);
	set.setValue("2", current_week);
	set.setValue("paa", is_rem);

}


void setCenter::saveCurrentDate()/*保存时间戳*/
{
	QSettings set("kebiao", "set");
	set.setValue("year", QDate::currentDate().toString("yyyy"));
	set.setValue("mon", QDate::currentDate().toString("M"));
	set.setValue("day", QDate::currentDate().toString("d"));
	set.setValue("week", QDate::currentDate().dayOfWeek());

}

void dataCenter::clear_cj()
{

	for (int i = 0; i < 25; i++)
	{
		dj_data[i].cj_chenji = "";
		dj_data[i].cj_name = "";
		dj_data[i].cj_pingshi = "";
		dj_data[i].cj_pro = "";
		dj_data[i].cj_qimo = "";
		dj_data[i].cj_xuefen = "";


	}

}


void  dataCenter::clear()
{

	for (int x = 0; x < 7; x++)
	{

		for (int y = 0; y < 14; y++)
		{

			for (int z = 0; z < 3; z++)
			{
				data[x][y][z].class_name = "";
				data[x][y][z].class_posi = "";
				data[x][y][z].class_pro = "";
				data[x][y][z].class_techer = "";
				data[x][y][z].class_time = "";

			}
		}
	}



}


float  PublicFunc::getFactory()
{
#ifdef Q_OS_WIN32
	return 1;
#endif // !Q_OS_WIN32



	int currentScreenWid = QApplication::desktop()->width();
	return currentScreenWid / MAX_X;

}


void  PublicFunc::resetGrid(QWidget *widget)
{

	double factorx;
	double factory;

	int currentScreenWid = QApplication::desktop()->width();
	int currentScreenHei = QApplication::desktop()->height();

	factorx = currentScreenWid / MAX_X;
	factory = currentScreenHei / MAX_Y;


	int widgetX = widget->x();
	int widgetY = widget->y();
	int widgetWid = widget->width();
	int widgetHei = widget->height();
	int nWidgetX = (int)(widgetX*factorx);
	int nWidgetY = (int)(widgetY*factory);
	int nWidgetWid = (int)(widgetWid*factorx);
	int nWidgetHei = (int)(widgetHei*factory);
	widget->setGeometry(nWidgetX, nWidgetY, nWidgetWid, nWidgetHei);

}







TableWidget::TableWidget(QWidget*p) :QTableWidget(p)
{

	this->setupUi((MainWindow*)p);
}





void detail_widget::slot_close()
{
	delete ui;
	delete this;

}


detail_widget::detail_widget(QWidget*p, int y, int x)
{
	ui = new Ui::detail_widget;


	ui->setupUi(this);

	connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(slot_close()));

	ui->label_2->setText(dataTable.data[x][y][0].class_name);

	ui->label_4->setText(dataTable.data[x][y][0].class_posi);

	ui->label_10->setText(dataTable.data[x][y][0].class_techer);

	ui->label_6->setText(dataTable.data[x][y][0].class_time);

	ui->label_8->setText(dataTable.data[x][y][0].class_pro);


	ui->label_2->setWordWrap(true);

	ui->label_6->setWordWrap(true);



#ifndef Q_OS_WIN32

	FixScreen();

#endif // !Q_OS_WIN32




}





void detail_widget::FixScreen()
{

	PublicFunc::resetGrid(ui->label);

	PublicFunc::resetGrid(ui->label_2);

	PublicFunc::resetGrid(ui->label_3);

	PublicFunc::resetGrid(ui->label_4);

	PublicFunc::resetGrid(ui->label_5);


	PublicFunc::resetGrid(ui->label_6);


	PublicFunc::resetGrid(ui->label_7);


	PublicFunc::resetGrid(ui->label_8);


	PublicFunc::resetGrid(ui->label_9);

	PublicFunc::resetGrid(ui->label_10);


	PublicFunc::resetGrid(ui->pushButton);


}








void cj_all_widget::slot_close()
{

	dataTable.clear_cj();

	listWidget_ref->clear();
	delete listWidget_ref;

	delete ui;
	delete this;

}


cj_all_widget::cj_all_widget(QWidget*p, int count)
{
	ui = new Ui::cj_all_widget;

	ui->setupUi(this);

	listWidget_ref = new ListWidget(this);

	connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(slot_close()));
	QFont font;
	font.setPointSize(14);


	listWidget_ref->clear();

	for (int i = 0; i < count; i++)
	{
		QListWidgetItem*it = new QListWidgetItem;

		it->setFont(font);

		it->setSizeHint(QSize(listWidget_ref->size().width(), 100 * PublicFunc::getFactory()));
		it->setText(" " + QVariant(i + 1).toString() + ". " + dataTable.dj_data[i].cj_name + "  " + dataTable.dj_data[i].cj_chenji);
		listWidget_ref->addItem(it);
	}


#ifndef Q_OS_WIN32

	FixScreen();



#endif // !Q_OS_WIN32



	this->show();

}





void cj_all_widget::FixScreen()
{
	PublicFunc::resetGrid(listWidget_ref);

	PublicFunc::resetGrid(ui->pushButton);

	PublicFunc::resetGrid(ui->label);




}







void detail_widget2::slot_close()
{
	delete ui;
	delete this;

}


detail_widget2::detail_widget2(QWidget*p, int y, int x)
{
	ui = new Ui::detail_widget2;


	ui->setupUi(this);

	connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(slot_close()));

	ui->label_2->setText(dataTable.data[x][y][0].class_name);

	ui->label_4->setText(dataTable.data[x][y][0].class_posi);

	ui->label_10->setText(dataTable.data[x][y][0].class_techer);

	ui->label_6->setText(dataTable.data[x][y][0].class_time);

	ui->label_8->setText(dataTable.data[x][y][0].class_pro);


	ui->label_2->setWordWrap(true);

	ui->label_4->setWordWrap(true);

	ui->label_10->setWordWrap(true);

	ui->label_6->setWordWrap(true);

	ui->label_8->setWordWrap(true);


	ui->label_14->setText(dataTable.data[x][y][1].class_name);

	ui->label_19->setText(dataTable.data[x][y][1].class_posi);

	ui->label_20->setText(dataTable.data[x][y][1].class_techer);

	ui->label_11->setText(dataTable.data[x][y][1].class_time);

	ui->label_17->setText(dataTable.data[x][y][1].class_pro);


	ui->label_14->setWordWrap(true);

	ui->label_19->setWordWrap(true);

	ui->label_20->setWordWrap(true);

	ui->label_11->setWordWrap(true);

	ui->label_17->setWordWrap(true);



#ifndef Q_OS_WIN32

	FixScreen();



#endif // !Q_OS_WIN32




}





void detail_widget2::FixScreen()
{

	PublicFunc::resetGrid(ui->label);
	PublicFunc::resetGrid(ui->label_2);
	PublicFunc::resetGrid(ui->label_3);
	PublicFunc::resetGrid(ui->label_4);
	PublicFunc::resetGrid(ui->label_5);
	PublicFunc::resetGrid(ui->label_6);
	PublicFunc::resetGrid(ui->label_7);
	PublicFunc::resetGrid(ui->label_8);
	PublicFunc::resetGrid(ui->label_9);
	PublicFunc::resetGrid(ui->label_10);
	PublicFunc::resetGrid(ui->label_11);
	PublicFunc::resetGrid(ui->label_12);
	PublicFunc::resetGrid(ui->label_13);
	PublicFunc::resetGrid(ui->label_14);
	PublicFunc::resetGrid(ui->label_15);
	PublicFunc::resetGrid(ui->label_16);
	PublicFunc::resetGrid(ui->label_17);
	PublicFunc::resetGrid(ui->label_18);
	PublicFunc::resetGrid(ui->label_19);
	PublicFunc::resetGrid(ui->label_20);

	PublicFunc::resetGrid(ui->line);



	PublicFunc::resetGrid(ui->pushButton);




}





void detail_widget3::slot_close()
{
	delete ui;
	delete this;

}


detail_widget3::detail_widget3(QWidget*p, int y, int x)
{
	ui = new Ui::detail_widget3;


	ui->setupUi(this);

	connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(slot_close()));

	ui->label_2->setText(dataTable.data[x][y][0].class_name);

	ui->label_4->setText(dataTable.data[x][y][0].class_posi);

	ui->label_10->setText(dataTable.data[x][y][0].class_techer);

	ui->label_6->setText(dataTable.data[x][y][0].class_time);


	ui->label_2->setWordWrap(true);

	ui->label_4->setWordWrap(true);

	ui->label_10->setWordWrap(true);

	ui->label_6->setWordWrap(true);


	ui->label_14->setText(dataTable.data[x][y][1].class_name);

	ui->label_19->setText(dataTable.data[x][y][1].class_posi);

	ui->label_20->setText(dataTable.data[x][y][1].class_techer);

	ui->label_11->setText(dataTable.data[x][y][1].class_time);


	ui->label_14->setWordWrap(true);

	ui->label_19->setWordWrap(true);

	ui->label_20->setWordWrap(true);

	ui->label_11->setWordWrap(true);


	ui->label_23->setText(dataTable.data[x][y][2].class_name);

	ui->label_25->setText(dataTable.data[x][y][2].class_posi);

	ui->label_28->setText(dataTable.data[x][y][2].class_techer);

	ui->label_21->setText(dataTable.data[x][y][2].class_time);


	ui->label_23->setWordWrap(true);

	ui->label_25->setWordWrap(true);

	ui->label_28->setWordWrap(true);

	ui->label_21->setWordWrap(true);



#ifndef Q_OS_WIN32

	FixScreen();



#endif // !Q_OS_WIN32




}





void detail_widget3::FixScreen()
{

	PublicFunc::resetGrid(ui->label);
	PublicFunc::resetGrid(ui->label_2);
	PublicFunc::resetGrid(ui->label_3);
	PublicFunc::resetGrid(ui->label_4);
	PublicFunc::resetGrid(ui->label_5);
	PublicFunc::resetGrid(ui->label_6);
	PublicFunc::resetGrid(ui->label_9);
	PublicFunc::resetGrid(ui->label_10);
	PublicFunc::resetGrid(ui->label_11);
	PublicFunc::resetGrid(ui->label_12);
	PublicFunc::resetGrid(ui->label_13);
	PublicFunc::resetGrid(ui->label_14);
	PublicFunc::resetGrid(ui->label_15);
	PublicFunc::resetGrid(ui->label_18);
	PublicFunc::resetGrid(ui->label_19);
	PublicFunc::resetGrid(ui->label_20);

	PublicFunc::resetGrid(ui->label_21);
	PublicFunc::resetGrid(ui->label_23);
	PublicFunc::resetGrid(ui->label_24);
	PublicFunc::resetGrid(ui->label_25);
	PublicFunc::resetGrid(ui->label_26);
	PublicFunc::resetGrid(ui->label_27);
	PublicFunc::resetGrid(ui->label_28);
	PublicFunc::resetGrid(ui->label_29);

	PublicFunc::resetGrid(ui->pushButton);

	PublicFunc::resetGrid(ui->line);
	PublicFunc::resetGrid(ui->line_2);



}





void detail_widget4::slot_close()
{
	delete ui;
	delete this;

}


detail_widget4::detail_widget4(QWidget*p, int index)
{
	ui = new Ui::detail_widget4;

	ui->setupUi(this);

	connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(slot_close()));

	ui->label_2->setText(dataTable.dj_data[index].cj_name);

	ui->label_4->setText(dataTable.dj_data[index].cj_pro);

	ui->label_10->setText(dataTable.dj_data[index].cj_xuefen);

	ui->label_6->setText(dataTable.dj_data[index].cj_pingshi);


	ui->label_14->setText(dataTable.dj_data[index].cj_qimo);
	ui->label_19->setText(dataTable.dj_data[index].cj_chenji);

	ui->label_2->setWordWrap(true);
	ui->label_4->setWordWrap(true);
	ui->label_10->setWordWrap(true);
	ui->label_6->setWordWrap(true);
	ui->label_14->setWordWrap(true);
	ui->label_19->setWordWrap(true);

#ifndef Q_OS_WIN32

	FixScreen();



#endif // !Q_OS_WIN32




}




void detail_widget4::FixScreen()
{

	PublicFunc::resetGrid(ui->label);


	PublicFunc::resetGrid(ui->label_2);


	PublicFunc::resetGrid(ui->label_3);


	PublicFunc::resetGrid(ui->label_4);


	PublicFunc::resetGrid(ui->label_5);


	PublicFunc::resetGrid(ui->label_6);


	PublicFunc::resetGrid(ui->label_9);

	PublicFunc::resetGrid(ui->label_10);



	PublicFunc::resetGrid(ui->label_14);
	PublicFunc::resetGrid(ui->label_13);
	PublicFunc::resetGrid(ui->label_15);


	PublicFunc::resetGrid(ui->label_19);

	PublicFunc::resetGrid(ui->pushButton);


}



void  bot_widget::setSendEnable(bool e)
{
	ui->pushButton_3->setVisible(e);


}


void  bot_widget::add_block_to_list()
{

	QListWidgetItem *item = new QListWidgetItem();

	item->setText("");

	QFont font;
	font.setFamily("simsun");
	font.setPointSize(14);

	ui->listWidget->addItem(item);
	item->setFont(font);
	item->setSizeHint(QSize(ui->listWidget->size().width(), 70 * PublicFunc::getFactory()));
}




void bot_widget::setTimerStart(int t)
{
	timer_out->start(t);/* 3 s*/

}



void  bot_widget::setTimerStop()
{
	timer_out->stop();

}



bool  bot_widget::parse()
{
	//	if (result == "")return false;

	if (result.indexOf("{") != 0)return false;
	if (result.size() <= 0)return false;


	return true;
}



void bot_widget::slot_close()
{
	manger->deleteLater();
	delete timer_out;

	delete ui;
	delete this;

}


bot_widget::bot_widget(QWidget*p)
{
	ui = new Ui::bot_widget;


	ui->setupUi(this);

	connect(ui->pushButton_4, SIGNAL(clicked()), this, SLOT(slot_close()));

	connect(ui->pushButton_3, SIGNAL(clicked()), this, SLOT(slot_send()));

	manger = new QNetworkAccessManager(this);

	connect(manger, SIGNAL(finished(QNetworkReply*)), this, SLOT(slot_doGet(QNetworkReply*)));

	ui->listWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);//去掉水平滚动条

	ui->listWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);//去掉水平滚动条

	//ui->listWidget->verticalScrollBar()->setEnabled(false);


	ui->listWidget->setSelectionBehavior(QAbstractItemView::SelectionBehavior::SelectItems);

	ui->listWidget->setSelectionMode(QAbstractItemView::SelectionMode::NoSelection);



#ifndef Q_OS_WIN32

	FixScreen();



#endif // !Q_OS_WIN32

	QListWidgetItem *item = new QListWidgetItem();

	item->setText(QTime::currentTime().toString("HH:mm:ss  ") + "\346\210\221\346\230\257\350\220\214\350\220\214\347\232\204\346\234\272\345\231\250\344\272\272\357\274\214\345\277\253\350\260\203\346\210\217\346\210\221\346\212\212\357\274\201");


	QIcon icon(":/2.png");
	QFont font;
	font.setFamily("simsun");
	font.setPointSize(14);
	item->setIcon(icon);

	ui->listWidget->addItem(item);
	item->setFont(font);
	item->setSizeHint(QSize(ui->listWidget->size().width(), 70 * PublicFunc::getFactory()));
	ui->listWidget->setIconSize(QSize(50 * PublicFunc::getFactory(), 50 * PublicFunc::getFactory()));

	timer_out = new QTimer(this);


	connect(timer_out, SIGNAL(timeout()), this, SLOT(slot_timer()));


}

void bot_widget::slot_timer()
{
	setTimerStop();
	ui->pushButton_3->setVisible(true);

	QMessageBox::warning(this, char_net_error, "\350\257\267\346\243\200\346\237\245\347\275\221\347\273\234\350\256\276\347\275\256");

}






void bot_widget::slot_doGet(QNetworkReply*reply)
{

	cout << (ui->listWidget->size().height() / 70 * PublicFunc::getFactory() - 3) << endl;

	if (ui->listWidget->count() > 6)
	{
		ui->listWidget->removeItemWidget(ui->listWidget->takeItem(0));
		ui->listWidget->update();


	}


	QByteArray binary = reply->readAll();

	result = QTextCodec::codecForName("utf8")->toUnicode(binary);

	if (parse() == false)
	{
		slot_timer();

		return;
	}
	else
	{
		setTimerStop();

	}


	result = result.mid(result.lastIndexOf(":") + 2, result.lastIndexOf('"') - result.lastIndexOf(":") - 2);

	QListWidgetItem *item = new QListWidgetItem();

	item->setText(QTime::currentTime().toString("HH:mm:ss  ") + result);
	QIcon icon(":/2.png");
	QFont font;
	font.setFamily("simsun");
	font.setPointSize(14);
	item->setIcon(icon);

	ui->listWidget->addItem(item);
	item->setFont(font);
	item->setSizeHint(QSize(ui->listWidget->size().width(), 70 * PublicFunc::getFactory()));
	ui->listWidget->setIconSize(QSize(50 * PublicFunc::getFactory(), 50 * PublicFunc::getFactory()));

	reply->deleteLater();



	setSendEnable(true);

}



void bot_widget::slot_send()
{


	//	if (ui->listWidget->count() > (ui->listWidget->size().height() / 70 * PublicFunc::getFactory() - 3))

	if (ui->listWidget->count() > 6)

	{
		ui->listWidget->removeItemWidget(ui->listWidget->takeItem(0));
		ui->listWidget->update();

	}


	if (ui->lineEdit->text() == "")
	{
		QMessageBox::warning(this, char_tixing, "\345\217\221\351\200\201\345\206\205\345\256\271\344\270\215\350\203\275\344\270\272\347\251\272");

		return;
	}

	setTimerStart();


	ui->lineEdit->setFocus();

	setSendEnable(false);

	QUrl url = "http://www.tuling123.com/openapi/api?key=c2bfc6d747d87f2e91619f0b7482b571&info= " + ui->lineEdit->text();

	QNetworkRequest request;
	request.setUrl(url);
	manger->get(request);


	QListWidgetItem *item = new QListWidgetItem();

	item->setText(QTime::currentTime().toString("HH:mm:ss  ") + ui->lineEdit->text());
	QIcon icon(":/icon.png");
	QFont font;
	font.setFamily("simsun");
	font.setPointSize(14);
	item->setIcon(icon);



	ui->listWidget->addItem(item);
	item->setFont(font);
	item->setSizeHint(QSize(ui->listWidget->size().width(), 50 * PublicFunc::getFactory()));
	ui->listWidget->setIconSize(QSize(50 * PublicFunc::getFactory(), 50 * PublicFunc::getFactory()));


	ui->lineEdit->setText("");
}







void bot_widget::FixScreen()
{


	PublicFunc::resetGrid(ui->pushButton_4);
	PublicFunc::resetGrid(ui->lineEdit);
	PublicFunc::resetGrid(ui->pushButton_3);
	PublicFunc::resetGrid(ui->listWidget);
	PublicFunc::resetGrid(ui->label);


}




void cet_widget::slot_close()
{
	setTimerStop();

	manger->deleteLater();

	delete ui;
	delete this;

}


cet_widget::cet_widget(QWidget*p)
{
	ui = new Ui::cet_widget;


	ui->setupUi(this);

	connect(ui->pushButton_4, SIGNAL(clicked()), this, SLOT(slot_close()));

	connect(ui->pushButton_3, SIGNAL(clicked()), this, SLOT(slot_send()));

	manger = new QNetworkAccessManager(this);

	connect(manger, SIGNAL(finished(QNetworkReply*)), this, SLOT(slot_doGet(QNetworkReply*)));

	timer_out = new QTimer(this);


	connect(timer_out, SIGNAL(timeout()), this, SLOT(slot_timer()));

	setTimerStop();

	QMovie *pm = new QMovie(":/loading.gif");

	ui->label_7->setMovie(pm);

	pm->setScaledSize(QSize(100 * PublicFunc::getFactory(), 30 * PublicFunc::getFactory()));

	pm->start(); //才会开始动

	QPixmap pix;
	pix.load(":/1.png");

	ui->label_6->setPixmap(pix);


#ifndef Q_OS_WIN32

	FixScreen();



#endif // !Q_OS_WIN32



}

void cet_widget::slot_timer()
{
	setTimerStop();
	QMessageBox::warning(this, char_net_error, "\350\257\267\346\243\200\346\237\245\347\275\221\347\273\234\350\256\276\347\275\256");

}





void cet_widget::slot_doGet(QNetworkReply*reply)
{


	QByteArray binary = reply->readAll();

	result = QTextCodec::codecForName("UTF8")->toUnicode(binary);

	result = result.mid(result.lastIndexOf("<table"), result.lastIndexOf("</table>") - result.lastIndexOf("<table"));
	setTimerStop();

	result.replace("th", "td");


	result.remove("\t");

	result.remove(0, result.indexOf(">") + 1);
	result.remove('"');

	result.remove("valign=");

	result.remove("top");
	result.remove("class");

	result.remove("<span");

	result.remove("fontBold");

	result.remove("color666");

	result.remove("colorRed");


	result.remove("</span>");

	result.remove("/>");

	result.remove(" ");

	result.remove("=");

	result.remove("\n");

	result.remove("<td>");
	result.remove("<tr>");

	result.remove("</td>");

	result.replace("</tr>", "\n");
	result.replace("<br>", "\n");
	result.remove(">");


	/*QFile file("ss.txt");
	file.open(QIODevice::WriteOnly);

	file.write(result.toStdString().c_str());
	file.flush();
	file.close();*/

	cout << result.lastIndexOf("<") << endl;

	if (result.lastIndexOf("<") == -1)
	{

		QMessageBox::warning(this, char_tixing, result);

	}
	else
	{
		QMessageBox::warning(this, char_tixing, "\346\234\252\346\237\245\345\210\260\346\210\220\347\273\251\357\274\214\350\257\267\346\243\200\346\237\245\350\276\223\345\205\245\346\230\257\345\220\246\346\255\243\347\241\256");

	}


}





void cet_widget::slot_send()
{
	/*输入规则判断
	*/

	if (ui->lineEdit->text().length() == 0)
	{

		QMessageBox::warning(this, char_tixing, "\350\257\267\350\276\223\345\205\24515\344\275\215\345\207\206\350\200\203\350\257\201");

		return;
	}

	if (ui->lineEdit_2->text().length() == 0)
	{

		QMessageBox::warning(this, char_tixing, "\350\257\267\346\255\243\347\241\256\350\276\223\345\205\245\345\247\223\345\220\215");

		return;
	}


	if (ui->lineEdit->text().length() < 15)
	{

		QMessageBox::warning(this, char_tixing, "\350\257\267\350\276\223\345\205\24515\344\275\215\345\207\206\350\200\203\350\257\201");

		return;
	}

	if (ui->lineEdit_2->text().length() <= 1)
	{

		QMessageBox::warning(this, char_tixing, "\350\257\267\346\255\243\347\241\256\350\276\223\345\205\245\345\247\223\345\220\215");

		return;
	}


	/**/


	setTimerStart();


	QString s = "http://www.chsi.com.cn/cet/query?";

	QUrlQuery query;
	query.addQueryItem("zkzh", ui->lineEdit->text());
	query.addQueryItem("xm", ui->lineEdit_2->text());

	s = s + query.toString(QUrl::FullyEncoded).toLatin1();

	QNetworkRequest request;

	request.setRawHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.111 Safari/537.36");

	request.setRawHeader("Connection", "Keep-Alive");

	request.setRawHeader("Host", "www.chsi.com.cn");

	request.setRawHeader("Referer", "http://www.chsi.com.cn/cet/");

	request.setUrl(QUrl(s));
	manger->get(request);


}







void cet_widget::setTimerStart(int t)
{
	ui->label_6->setVisible(true);
	ui->label_7->setVisible(true);

	timer_out->start(t);/* 3 s*/
	ui->pushButton_3->setVisible(false);

}



void cet_widget::setTimerStop()
{
	ui->label_6->setVisible(false);
	ui->label_7->setVisible(false);

	ui->pushButton_3->setVisible(true);
	timer_out->stop();

}



void cet_widget::FixScreen()
{

	PublicFunc::resetGrid(ui->pushButton_4);
	PublicFunc::resetGrid(ui->lineEdit);
	PublicFunc::resetGrid(ui->pushButton_3);
	PublicFunc::resetGrid(ui->label);


	PublicFunc::resetGrid(ui->label_2);
	PublicFunc::resetGrid(ui->label_3);


	PublicFunc::resetGrid(ui->lineEdit_2);

	PublicFunc::resetGrid(ui->label_6);

	PublicFunc::resetGrid(ui->label_7);


}







void loading_widget::slot_close()
{

	delete ui;
	delete this;

}


loading_widget::loading_widget(QWidget*p)
{
	/*ui = new Ui::loading_widget;


	ui->setupUi(this);



	QMovie *pm = new QMovie("loading.gif");

	ui->label->setMovie(pm);

	pm->setScaledSize(QSize(100 * PublicFunc::getFactory(), 30 * PublicFunc::getFactory()));

	pm->start(); //才会开始动

	*/




#ifndef Q_OS_WIN32

	//FixScreen();



#endif // !Q_OS_WIN32




}



void loading_widget::FixScreen()
{

	PublicFunc::resetGrid(ui->label);


}




int  MainWindow::getMinWeek(QString time)/*获得区间最小周*/
{
	/*BUG 当该课的时间不止一个时候始终返回第一个时间   fixed*/


	/*周二第11,12节{第1-8周}*/



	int x = time.indexOf("{");
	QVariant tmp;

	if (x == time.lastIndexOf("{"))
	{/*只有一*/
		tmp = time.mid(x + 2, time.indexOf("}") - x - 3);
		time = tmp.toString();
		time = time.mid(0, time.indexOf("-"));
		return QVariant(time).toInt();
	}
	else
	{

		x = time.lastIndexOf("{");
		tmp = time.mid(x + 2, time.lastIndexOf("}") - x - 3);
		time = tmp.toString();
		time = time.mid(0, time.lastIndexOf("-"));
		return QVariant(time).toInt();

	}



}


int  MainWindow::getMaxWeek(QString time)
{
	/*周二第11,12节{第1-8周}*/

	int x = time.indexOf("{");
	QVariant tmp;

	if (x == time.lastIndexOf("{"))
	{/*只有一*/

		tmp = time.mid(x + 2, time.lastIndexOf("}") - x - 3);
		time = tmp.toString();
		time = time.mid(time.lastIndexOf("-") + 1, -1);

		//return tmp.toInt();

		return QVariant(time).toInt();

	}
	else
	{
		x = time.lastIndexOf("{");

		tmp = time.mid(x + 2, time.lastIndexOf("}") - x - 3);
		time = tmp.toString();
		time = time.mid(time.lastIndexOf("-") + 1, -1);
		return QVariant(time).toInt();
	}


}










bool MainWindow::is_on_this_week(int row, int col, int i)/*课程在本周 返回true*/
{

	return setCenter::current_week >= getMinWeek(dataTable.data[row][col][i].class_time) &&
		setCenter::current_week <= getMaxWeek(dataTable.data[row][col][i].class_time);

}
bool  MainWindow::is_on_this_week(int row, int col, int i, int cur)
{

	return cur >= getMinWeek(dataTable.data[row][col][i].class_time) &&
		cur <= getMaxWeek(dataTable.data[row][col][i].class_time);

}



void MainWindow::loadTable()
{


	char s[200];

	QSettings set("kebiao", "1");


	for (int x = 0; x < 7; x++)
	{

		for (int y = 0; y < 14; y++)
		{

			for (int z = 0; z < 3; z++)
			{

				sprintf(s, "%d.%d.%d.name", x, y, z);
				dataTable.data[x][y][z].class_name = set.value(s).toString();


				sprintf(s, "%d.%d.%d.posi", x, y, z);
				dataTable.data[x][y][z].class_posi = set.value(s).toString();

				sprintf(s, "%d.%d.%d.pro", x, y, z);
				dataTable.data[x][y][z].class_pro = set.value(s).toString();

				sprintf(s, "%d.%d.%d.tec", x, y, z);
				dataTable.data[x][y][z].class_techer = set.value(s).toString();

				sprintf(s, "%d.%d.%d.time", x, y, z);
				dataTable.data[x][y][z].class_time = set.value(s).toString();

			}
		}
	}




}







void MainWindow::saveTable()
{

	char ss[200];

	QSettings set("kebiao", "1");

	for (int x = 0; x < 7; x++)
	{

		for (int y = 0; y < 14; y++)
		{

			for (int z = 0; z < 3; z++)
			{
				sprintf(ss, "%d.%d.%d.posi", x, y, z);
				set.setValue(ss, dataTable.data[x][y][z].class_posi);

				sprintf(ss, "%d.%d.%d.name", x, y, z);
				set.setValue(ss, dataTable.data[x][y][z].class_name);

				sprintf(ss, "%d.%d.%d.pro", x, y, z);
				set.setValue(ss, dataTable.data[x][y][z].class_pro);

				sprintf(ss, "%d.%d.%d.tec", x, y, z);
				set.setValue(ss, dataTable.data[x][y][z].class_techer);

				sprintf(ss, "%d.%d.%d.time", x, y, z);
				set.setValue(ss, dataTable.data[x][y][z].class_time);


			}
		}
	}


}

void  MainWindow::syncTable(int index)
{

	QString tmp;

	for (int xx = 0; xx < 14; xx += 2)
	{
		for (int i = 0; i < 7; i++)
		{
			tmp = "";
			for (int k = 2; k >= 0; k--)
			{
				if (dataTable.data[i][xx][k].class_name.size() > 1)
				{
					if (is_on_this_week(i, xx, k, index))
					{
						tmp = dataTable.data[i][xx][k].class_name + dataTable.data[i][xx][k].class_posi;
						break;
					}
					else
					{
						if (setCenter::is_show_all == true)
						{
							tmp = dataTable.data[i][xx][k].class_name + dataTable.data[i][xx][k].class_posi;
						}

					}

				}

			}


			QTableWidgetItem* z = new QTableWidgetItem(tmp);
			z->setTextAlignment(Qt::AlignCenter);

			tableWidget->setItem(xx, i, z);
			if (xx % 4)
			{
				tableWidget->item(xx, i)->setBackgroundColor(QColor(245, 245, 245));

			}
			QFont font;
			font.setPointSize(9);
			font.setFamily("simsun");

			z->setFont(font);


		}


	}
	if (setCenter::current_week == index)
	{
		ui->pushButton_4->setText(QVariant(index).toString() + char_week + char_curr_week);

	}
	else
		ui->pushButton_4->setText(QVariant(index).toString() + char_week + char_not_curr_week);

	//now_week = setCenter::current_week;

	saveTable();
}






void MainWindow::slot_move(int a, int b, int c, int d)
{
	if (a > c)
	{

		tableWidget->verticalScrollBar()->setValue(tableWidget->verticalScrollBar()->minimum());

	}
	else
	{
		tableWidget->verticalScrollBar()->setValue(tableWidget->verticalScrollBar()->maximum());

	}
}



void MainWindow::slot_curr()
{
	syncTable(setCenter::current_week);
	now_week = setCenter::current_week;

}



void  MainWindow::slot_next()
{
	if (now_week > 24)return;
	syncTable(++now_week);

}


void MainWindow::slot_pre()
{
	if (now_week < 2)return;
	syncTable(--now_week);

}





void MainWindow::slot_set()
{
	syncTable(setCenter::current_week);
	now_week = setCenter::current_week;

	set_widget* x = new set_widget(this);
	x->show();


}




void  MainWindow::slot_new()
{
	is_kebiao = true;

	login_widget_ref->exec();
	//QMessageBox::warning(login_widget_ref, char_tixing, char_new);
}

void MainWindow::slot_click(int x, int y)
{

	tableWidget->setCurrentCell(x, y);


	if (dataTable.data[y][x][2].class_name != "")
	{

		detail_widget3* xx = new detail_widget3(this, x, y);
		xx->show();

	}


	else if (dataTable.data[y][x][1].class_name != "")
	{

		detail_widget2* xx = new detail_widget2(this, x, y);
		xx->show();

	}
	else if (dataTable.data[y][x][0].class_name != "")
	{

		detail_widget* xx = new detail_widget(this, x, y);
		xx->show();

	}
	else
	{

	}


}





void MainWindow::initTableUI()
{



}





MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
	ui->setupUi(this);
	tableWidget = new TableWidget(this);

	connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(close()));

	connect(ui->pushButton_2, SIGNAL(clicked()), this, SLOT(slot_set()));

	connect(ui->pushButton_4, SIGNAL(clicked()), this, SLOT(slot_curr()));

	tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); //设置不可编辑


	tableWidget->setSelectionBehavior(QAbstractItemView::SelectItems); //设置选择行为，以行为单位
	tableWidget->setSelectionMode(QAbstractItemView::NoSelection); //设置选择模式，选择单行

	tableWidget->setShowGrid(true);//显示表格线
	tableWidget->setAutoScroll(true);
	tableWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);//去掉水平滚动条
	tableWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);//去掉水平滚动条

	loadTable();



	//#ifndef Q_OS_WIN32


	PublicFunc::resetGrid(ui->pushButton);
	PublicFunc::resetGrid(ui->pushButton_2);


	PublicFunc::resetGrid(ui->pushButton_3);
	PublicFunc::resetGrid(ui->pushButton_5);

	PublicFunc::resetGrid(ui->pushButton_4);


	QFont font;
	font.setPointSize(8);
	font.setFamily("simsun");

	//ui->tableWidget->horizontalHeader()->setDefaultSectionSize(88 * PublicFunc::getFactory());


	QFont font1;
	font1.setPointSize(13);
	font1.setFamily("simsun");

	//	ui->tableWidget->verticalHeader()->setFont(font);
	//ui->tableWidget->horizontalHeader()->setFont(font1);
	tableWidget->verticalHeader()->setFont(font);
	tableWidget->horizontalHeader()->setFont(font1);

	login_widget_ref = new login_widget(this);


	connect(tableWidget, SIGNAL(cellClicked(int, int)), this, SLOT(slot_click(int, int)));

	QTimer *timer_1S = new QTimer;
	connect(timer_1S, SIGNAL(timeout()), this, SLOT(slot_timer_1s()));



	tableWidget->verticalScrollBar()->setValue(tableWidget->verticalScrollBar()->minimum());

	now_week = setCenter::current_week;
	connect(ui->pushButton_3, SIGNAL(clicked()), this, SLOT(slot_pre()));
	connect(ui->pushButton_5, SIGNAL(clicked()), this, SLOT(slot_next()));

	syncTable(setCenter::current_week);

	timer_1S->start(100);
	slot_timer_1s();


	this->show();



	if (is_first == true)
	{
		is_first = false;
		slot_new();

	}


}





void MainWindow::slot_timer_1s()
{

	/*今天提醒*/

	int week = QDate::currentDate().dayOfWeek() - 1;
	for (int i = 0; i < 7; i++)
	{

		tableWidget->horizontalHeaderItem(i)->setTextColor(QColor(0, 0, 0));

	}

	tableWidget->horizontalHeaderItem(week)->setTextColor(QColor(255, 0, 0));


	/**/
	for (int i = 0; i < 14; i++)
	{

		for (int i1 = 0; i1 < 7; i1++)
		{

			if (tableWidget->item(i, i1))
			{

				tableWidget->item(i, i1)->setTextColor(QColor(0, 0, 0));
			}

		}
	}


	time = QTime::currentTime().hour() * 60 + QTime::currentTime().minute();


	if (time > 495 && time < 600)
	{
		if (tableWidget->item(0, week))
		{
			for (int i = 0; i < 3; i++)
			{
				if (is_on_this_week(week, 0, i, now_week))
				{
					/*只要有一个在本周 那么就显示颜色*/
					tableWidget->item(0, week)->setTextColor(QColor(255, 0, 0));
					break;
				}
			}
		}
		return;

	}


	if (time > 620 && time < 720)
	{
		if (tableWidget->item(2, week))
		{
			for (int i = 0; i < 3; i++)
			{
				if (is_on_this_week(week, 2, i, now_week))
				{
					/*只要有一个在本周 那么就显示颜色*/
					tableWidget->item(2, week)->setTextColor(QColor(255, 0, 0));
					break;
				}
			}
		}
		return;
	}


	if (time > 760 && time < 840)
	{
		if (tableWidget->item(4, week))
		{
			for (int i = 0; i < 3; i++)
			{
				if (is_on_this_week(week, 4, i, now_week))
				{
					/*只要有一个在本周 那么就显示颜色*/
					tableWidget->item(4, week)->setTextColor(QColor(255, 0, 0));
					break;
				}
			}
		}
		return;

	}


	if (time > 870 && time < 970)
	{
		if (tableWidget->item(6, week))
		{
			for (int i = 0; i < 3; i++)
			{
				if (is_on_this_week(week, 6, i, now_week))
				{
					/*只要有一个在本周 那么就显示颜色*/
					tableWidget->item(6, week)->setTextColor(QColor(255, 0, 0));
					break;
				}
			}
		}
		return;
	}

	if (time > 980 && time < 1080)
	{

		if (tableWidget->item(8, week))
		{
			for (int i = 0; i < 3; i++)
			{
				if (is_on_this_week(week, 8, i, now_week))
				{
					/*只要有一个在本周 那么就显示颜色*/
					tableWidget->item(8, week)->setTextColor(QColor(255, 0, 0));
					break;
				}
			}
		}
		return;
	}



	if (time > 1140 && time < 1240)
	{
		if (tableWidget->item(10, week))
		{
			for (int i = 0; i < 3; i++)
			{
				if (is_on_this_week(week, 10, i, now_week))
				{
					/*只要有一个在本周 那么就显示颜色*/
					tableWidget->item(10, week)->setTextColor(QColor(255, 0, 0));
					break;
				}
			}
		}
		return;
	}


}





login_widget::login_widget(QWidget *parent) ://QWidget(parent),
ui(new Ui::login_widget)
{

	ui->setupUi(this);
	p = (MainWindow*)parent;

	//loading = new loading_widget(this);


#ifndef Q_OS_WIN32
	FixScreen();


#endif


	timer_timeout = new QTimer(this);

	connect(timer_timeout, SIGNAL(timeout()), this, SLOT(slot_timer()));

	manager = new QNetworkAccessManager(this);


	connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(doManagerFinished(QNetworkReply*)));

	connect(ui->pushButton_2, SIGNAL(clicked()), this, SLOT(slot_verfy()));
	connect(ui->pushButton_3, SIGNAL(clicked()), this, SLOT(slot_close()));
	connect(ui->pushButton_4, SIGNAL(clicked()), this, SLOT(slot_shuom()));


	captchaUrl = QUrl("http://61.139.105.138/CheckCode.aspx");

	homepageUrl = QUrl("http://61.139.105.138/default2.aspx");

	QMovie *pm = new QMovie(":/loading.gif");

	ui->label_7->setMovie(pm);

	pm->setScaledSize(QSize(100 * PublicFunc::getFactory(), 30 * PublicFunc::getFactory()));

	pm->start(); //才会开始动

	QPixmap pix;
	pix.load(":/1.png");

	ui->label_6->setPixmap(pix);

	setHide();


}



void login_widget::slot_timer()
{
	timer_timeout->stop();
	setHide();

	QMessageBox::warning(this, char_net_error, char_net_error_center);

	slot_close();


}




void login_widget::setShow()
{
	ui->label_6->setVisible(true);
	ui->label_7->setVisible(true);

}


void login_widget::setStart(int time)/*超时15 S*/
{
	timer_timeout->start(time);

}


void   login_widget::setHide()
{

	ui->label_6->setVisible(false);
	ui->label_7->setVisible(false);

}



login_widget::~login_widget()
{
	cout << "call login_widget disstruct" << endl;
}




void login_widget::setLoginVisiable(bool is)
{
	ui->pushButton->setVisible(is);

	ui->pushButton_2->setVisible(is);

	ui->lineEdit->setVisible(is);

	ui->lineEdit_2->setVisible(is);

	ui->lineEdit_3->setVisible(is);

	ui->label->setVisible(is);

	ui->label_2->setVisible(is);

	ui->label_3->setVisible(is);

	ui->label_4->setVisible(is);

}





void login_widget::doManagerFinished(QNetworkReply *reply)
{
	timer_timeout->stop();

	QByteArray binary = reply->readAll();
	if (binary.size() <= 0)
	{
		setHide();
		QMessageBox::warning(this, "\347\275\221\347\273\234\351\224\231\350\257\257", "\350\257\267\346\243\200\346\237\245\347\275\221\347\273\234\350\277\236\346\216\245");
		
	//reply->deleteLater();
		delete reply;

		return;

	}



	QString result = QTextCodec::codecForName("gb2312")->toUnicode(binary);
	if (reply->url() == homepageUrl)
	{
		/*登陆*/

		if (reply->operation() == QNetworkAccessManager::GetOperation)
		{
			QRegExp reg("name=\"__VIEWSTATE\" value=\"([^\"]+)\"");
			if (reg.indexIn(result) != -1)
			{
				viewstate = reg.cap(1);
			}

			if (reply->rawHeader("Set-Cookie").length())
			{
				jsessionid = reply->rawHeader("Set-Cookie");
				jsessionid = jsessionid.left(jsessionid.indexOf(';'));
			}
			else
			{

			}

			slot_verfy();
		}
		else
		{

			setStart();
			QNetworkRequest request;
			request.setRawHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.3; WOW64; Trident/8.0)");
			request.setRawHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
			request.setRawHeader("Accept-Encoding", "gzip, deflate");
			request.setRawHeader("Accept-Language", "zh-CN,zh;q=0.8");
			request.setRawHeader("Cache-Control", "max-age=0");
			request.setRawHeader("Cookie", jsessionid.toLatin1());
			request.setRawHeader("Connection", "Keep-Alive");

			QUrl mainpageUrl = QUrl("http://61.139.105.138" + reply->rawHeader("Location"));
			//     qDebug() << mainpageUrl;
			request.setUrl(QUrl(mainpageUrl));
			manager->get(request);


			setShow();
		}
	}


	else if (reply->url() == captchaUrl)
	{
		/*验证码*/
		QPixmap pixmap;

		if (pixmap.loadFromData(binary))
		{

			setHide();


			ui->label->setVisible(true);
			ui->pushButton->setVisible(true);


#ifndef Q_OS_WIN32
			ui->label->setPixmap(pixmap.scaled(72 * 2.2 * PublicFunc::getFactory(), 27 * 2.2*PublicFunc::getFactory(), Qt::KeepAspectRatio));
#else
			ui->label->setPixmap(pixmap);
#endif

		}
	}

	else if (reply->url() == url_kebiao)
	{
		/*课表*/

		dataTable.clear();

		//ui->textEdit->append(QString::fromLocal8Bit(binary.data()));

		{
			QSettings set("kebiao", "set");

			set.setValue(("xuehao"), ui->lineEdit_2->text());

			if (setCenter::is_rem)
			{
				set.setValue(("mima"), ui->lineEdit_3->text());

			}
			else
			{

				set.setValue(("mima"), "");
			}


		}

		QString data = QString::fromLocal8Bit(binary.data());

		/**/
		int x = data.indexOf("trbg1") + 10;
		int y = data.indexOf("datelist");
		data = data.mid(x, y - x);

		x = data.indexOf("trbg1") + 10;


		info = (data.mid(x, data.indexOf("labTip") - x));


		x = data.indexOf("Table1") - 11;
		y = data.indexOf("</table>");

		data = data.mid(x, data.size() - x);
		data = data.mid(0, data.indexOf("</table>"));


		x = data.indexOf("</tr>") + 5;
		data = data.mid(x, -1);

		x = data.indexOf("</tr>") + 5;
		data = data.mid(x, -1);

		QString tm;

		x = info.indexOf("&nbsp");
		info = info.mid(0, x);

		x = info.indexOf(">");
		info = info.mid(x + 1, -1);

		info.remove("|");

		info.remove("</span>");

		info.remove(info.indexOf("<"), info.indexOf(">") - info.indexOf("<") + 1);
		info.remove(info.indexOf("<"), info.indexOf(">") - info.indexOf("<") + 1);
		info.remove(info.indexOf("<"), info.indexOf(">") - info.indexOf("<") + 1);
		info.remove(info.indexOf("<"), info.indexOf(">") - info.indexOf("<") + 1);
		info.remove(info.indexOf("<"), info.indexOf(">") - info.indexOf("<") + 1);

		info.remove("\t");

		setHide();


		info.insert(0, "\n");

		QMessageBox::warning(this, "\350\257\276\350\241\250\344\277\241\346\201\257", info);/*课表信息*/

		QSettings set("kebiao", "1");
		set.setValue("info", info);

		/*分割完成 接下来 提取每一行数据 一共14行*/


		for (int i = 0; i < 14; i++)
		{
			x = data.indexOf("<tr>");
			y = data.indexOf("</tr>") + 5;
			class_arry[i] = data.mid(x, y - x);
			data = data.mid(y, -1);

			//	data.remove(class_arry[i]);

		}

		/*提取每一行完毕 开始分割列*/
		QString day[15];

		QString tmp;

		for (int xx = 0; xx < 14; xx += 2)
		{

			class_arry[xx].remove("</tr>");
			class_arry[xx].remove("<tr>");


			for (int i = 0; i < 7; i++)
			{
				x = class_arry[xx].lastIndexOf("<td");
				y = class_arry[xx].lastIndexOf("</td>") + 5;
				day[i] = class_arry[xx].mid(x, y - x);

				class_arry[xx] = class_arry[xx].mid(0, x);
				day[i].remove(day[i].mid(0, day[i].indexOf(">") + 1));

				day[i].remove("&nbsp;</td>");

				day[i].remove("</td>");
				day[i].replace("<br>", ".");


				/*取出每一节课完成 开始取出每一节课信息*/

				for (int iii = 0; iii < 3; iii++)
				{

					/*取出名字*/
					y = day[i].indexOf(".");
					tmp = day[i].mid(0, y);
					dataTable.data[6 - i][xx][iii].class_name = tmp;
					//	day[i].remove(tmp + ".");

					day[i] = day[i].mid(y + 1, -1);

					/*课程性质*/
					y = day[i].indexOf(".");
					tmp = day[i].mid(0, y);
					dataTable.data[6 - i][xx][iii].class_pro = tmp;
					tmp = tmp + ".";
					//	day[i].remove(tmp);

					day[i] = day[i].mid(y + 1, -1);


					/*时间*/
					y = day[i].indexOf(".");
					tmp = day[i].mid(0, y);
					dataTable.data[6 - i][xx][iii].class_time = tmp;
					tmp = tmp + ".";
					//day[i].remove(tmp);

					day[i] = day[i].mid(y + 1, -1);


					/*老师*/
					y = day[i].indexOf(".");
					tmp = day[i].mid(0, y);
					dataTable.data[6 - i][xx][iii].class_techer = tmp;
					tmp = tmp + ".";
					//day[i].remove(tmp);
					day[i] = day[i].mid(y + 1, -1);



					/*地点*/
					y = day[i].indexOf(".");
					if (y <= 0)
					{
						dataTable.data[6 - i][xx][iii].class_posi = day[i];
						day[i] = "";
					}
					else
					{

						tmp = day[i].mid(0, y);
						dataTable.data[6 - i][xx][iii].class_posi = tmp;
						tmp = tmp + "..";
						//day[i].remove(tmp);

						day[i] = day[i].mid(y + 2, -1);


					}
					if (day[i].size() < 1)break;

				}

				/*	QTableWidgetItem* z = new QTableWidgetItem(day[i]);
					z->setTextAlignment(Qt::AlignCenter);


					p->ui->tableWidget->setItem(xx, 6 - i, z);
					p->ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); //设置不可编辑

					p->ui->tableWidget->horizontalHeader()->resizeSection(6 - i, 80 * PublicFunc::getFactory()); //设置表头第一列的宽度为150

					p->ui->tableWidget->setRowHeight(xx, PublicFunc::getFactory() * 100);
					p->ui->tableWidget->setRowHeight(xx + 1, 0);

					QFont font;
					font.setPointSize(12);


					font.setFamily("simsun");

					z->setFont(font);*/

			}


		}
		p->syncTable(setCenter::current_week);


		QMessageBox::information(this, "\346\217\220\347\244\272", "\345\257\274\345\205\245\350\257\276\350\241\250\346\210\220\345\212\237");/*错误*/

		/*提示 导入课表成功*/


		ui->pushButton->setVisible(true);

		slot_close();

	}


	else if (reply->url() == url_chenji)
	{

		if (reply->operation() == QNetworkAccessManager::GetOperation)
		{
			/*get*/
			QRegExp reg("name=\"__VIEWSTATE\" value=\"([^\"]+)\"");
			if (reg.indexIn(result) != -1)
			{
				viewstate = reg.cap(1);
			}

			if (reply->rawHeader("Set-Cookie").length())
			{
				jsessionid = reply->rawHeader("Set-Cookie");
				jsessionid = jsessionid.left(jsessionid.indexOf(';'));
			}

			setStart();
			url_chenji = QUrl("http://61.139.105.138/xscjcx_dq.aspx?xh=" + ui->lineEdit_2->text());/*成绩*/
			QNetworkRequest request;
			request.setRawHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.3; WOW64; Trident/8.0)");
			request.setRawHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
			request.setRawHeader("Accept-Encoding", "gzip, deflate");
			request.setRawHeader("Accept-Language", "zh-CN,zh;q=0.8");
			request.setRawHeader("Cache-Control", "max-age=0");
			request.setRawHeader("Cookie", jsessionid.toLatin1());
			request.setRawHeader("Connection", "Keep-Alive");
			QString ss = "http://61.139.105.138/xscjcx_dq.aspx?xh=" + ui->lineEdit_2->text();///表
			request.setRawHeader("Referer", ss.toStdString().c_str());

			QUrl mainpageUrl = QUrl(ss);
			request.setUrl(QUrl(url_chenji));

			QUrlQuery query;
			query.addQueryItem("__EVENTTARGET", "ddlxn");
			query.addQueryItem("__EVENTARGUMENT", "");
			query.addQueryItem("__VIEWSTATE", viewstate);
			QString xueqi;
			char xuen[30];


			QDate date = QDate::currentDate();

			if (date.month() >= 6 && date.month() <= 10)
			{
				/*第二学期*/
				xueqi = "2";
				sprintf(xuen, "%d-%d", date.year() - 1, date.year());
			}
			else 	if (date.month() > 10)
			{
				/*第1学期*/
				xueqi = "1";
				sprintf(xuen, "%d-%d", date.year(), date.year() + 1);
			}

			else
			{
				/*第1学期*/
				xueqi = "1";
				sprintf(xuen, "%d-%d", date.year() - 1, date.year());

			}
			query.addQueryItem("ddlxn", xuen);
			query.addQueryItem("ddlxq", xueqi);

			query.addQueryItem("btnCx", "+%B2%E9++%D1%AF+");

			QByteArray postData = query.toString(QUrl::FullyEncoded).replace("+", "%2B").toLatin1();

			manager->post(request, postData);

			setShow();


		}
		else if (reply->operation() == QNetworkAccessManager::PostOperation)
		{
			/*post*/


			ui->pushButton->setVisible(true);
			setHide();

			do_chengji(binary);

		}

	}
	else
	{

		setHide();

		/*登陆后*/
		QString s = binary.data();

		if (s.indexOf("main_html") <= 0)
		{
			/*登陆失败*/
			slot_verfy();
			QMessageBox::warning(this, "\351\224\231\350\257\257", "\345\257\206\347\240\201\346\210\226\351\252\214\350\257\201\347\240\201");/*错误*/

			/*登陆失败*/
		}
		else
		{
			/*登陆成功 开始获取课表*/

			if (is_kebiao)
			{
				slot_getKebiao();
			}
			else
				slot_getChenJi();

			//	setLoginVisiable(false);

		}
	}


	//reply->deleteLater();
	delete reply;

}



void login_widget::on_pushButton_clicked()
{


	/*输入规则判断*/
	if (ui->lineEdit_2->text().length() < 11)
	{
		QMessageBox::warning(this, char_tixing, "\350\257\267\346\255\243\347\241\256\350\276\223\345\205\245\345\255\246\345\217\267");

		return;
	}


	if (ui->lineEdit_3->text().length() == 0)
	{
		QMessageBox::warning(this, char_tixing, "\345\257\206\347\240\201\344\270\215\350\203\275\344\270\272\347\251\272");

		return;
	}

	if (ui->lineEdit->text().length() == 0)
	{
		QMessageBox::warning(this, char_tixing, "\350\257\267\350\276\223\345\205\245\351\252\214\350\257\201\347\240\201");

		return;
	}


	if (ui->lineEdit->text().length() < 4)
	{
		QMessageBox::warning(this, char_tixing, "\351\252\214\350\257\201\347\240\201\351\224\231\350\257\257");

		return;
	}

	ui->pushButton->setVisible(false);


	/*登陆*/

	setStart();
	setShow();

	QNetworkRequest request;
	request.setUrl(homepageUrl);
	request.setRawHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.3; WOW64; Trident/8.0)");
	request.setRawHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
	request.setRawHeader("Accept-Encoding", "gzip, deflate");
	request.setRawHeader("Accept-Language", "zh-CN,zh;q=0.8");
	request.setRawHeader("Cache-Control", "max-age=0");
	request.setRawHeader("Cookie", jsessionid.toLatin1());
	request.setRawHeader("Connection", "Keep-Alive");
	QUrlQuery query;
	query.addQueryItem("__VIEWSTATE", viewstate);
	query.addQueryItem("txtUserName", ui->lineEdit_2->text());
	query.addQueryItem("TextBox2", ui->lineEdit_3->text());
	query.addQueryItem("txtSecretCode", ui->lineEdit->text());
	query.addQueryItem("RadioButtonList1", "%D1%A7%C9%FA");
	query.addQueryItem("Button1", "");
	query.addQueryItem("lbLanguage", "");
	query.addQueryItem("hidPdrs", "");
	query.addQueryItem("hidsc", "");
	QByteArray postData = query.toString(QUrl::FullyEncoded).replace("+", "%2B").toLatin1();

	//  qDebug() << postData;

	request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
	request.setHeader(QNetworkRequest::ContentLengthHeader, postData.length());
	manager->post(request, postData);


}





void  login_widget::slot_verfy()
{

	setShow();

	setStart();

	ui->lineEdit->setText("");
	ui->pushButton->setVisible(false);

	ui->label->setVisible(false);

	QNetworkRequest request;
	request.setRawHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.3; WOW64; Trident/8.0)");
	request.setRawHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
	request.setRawHeader("Accept-Encoding", "gzip, deflate");
	request.setRawHeader("Accept-Language", "zh-CN,zh;q=0.8");
	request.setRawHeader("Cache-Control", "max-age=0");
	request.setRawHeader("Cookie", jsessionid.toLatin1());
	request.setRawHeader("Connection", "Keep-Alive");

	request.setUrl(captchaUrl);
	manager->get(request);
}






void login_widget::slot_getKebiao()
{
	setShow();

	setStart();
	url_kebiao = QUrl("http://61.139.105.138/xskbcx.aspx?xh=" + ui->lineEdit_2->text());/*课表*/
	QNetworkRequest request;
	request.setRawHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.3; WOW64; Trident/8.0)");
	request.setRawHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
	request.setRawHeader("Accept-Encoding", "gzip, deflate");
	request.setRawHeader("Accept-Language", "zh-CN,zh;q=0.8");
	request.setRawHeader("Cache-Control", "max-age=0");
	request.setRawHeader("Cookie", jsessionid.toLatin1());
	request.setRawHeader("Connection", "Keep-Alive");

	QString ss = "http://61.139.105.138/xskbcx.aspx?xh=" + ui->lineEdit_2->text();///表

	request.setRawHeader("Referer", ss.toStdString().c_str());

	QUrl mainpageUrl = QUrl(ss);
	request.setUrl(QUrl(url_kebiao));
	manager->get(request);

}





void login_widget::slot_getChenJi()
{
	setShow();

	setStart();

	url_chenji = QUrl("http://61.139.105.138/xscjcx_dq.aspx?xh=" + ui->lineEdit_2->text());/*成绩*/
	QNetworkRequest request;
	request.setRawHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.3; WOW64; Trident/8.0)");
	request.setRawHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
	request.setRawHeader("Accept-Encoding", "gzip, deflate");
	request.setRawHeader("Accept-Language", "zh-CN,zh;q=0.8");
	request.setRawHeader("Cache-Control", "max-age=0");
	request.setRawHeader("Cookie", jsessionid.toLatin1());
	request.setRawHeader("Connection", "Keep-Alive");
	QString ss = "http://61.139.105.138/xscjcx_dq.aspx?xh=" + ui->lineEdit_2->text();///表
	request.setRawHeader("Referer", ss.toStdString().c_str());


	QUrl mainpageUrl = QUrl(ss);
	request.setUrl(QUrl(url_chenji));
	manager->get(request);


}






void login_widget::slot_close()
{

	manager->clearAccessCache();
	
	timer_timeout->stop();
	setHide();

	this->hide();
}



void   login_widget::slot_shuom()
{
	QMessageBox::warning(this, char_tixing, "\n\347\263\273\347\273\237\350\207\252\345\212\250\351\200\202\351\205\215\345\255\246\345\271\264\345\222\214\345\255\246\346\234\237\n\n\346\211\200\344\273\245\346\202\250\346\237\245\345\210\260\347\232\204\345\247\213\347\273\210\346\230\257\344\275\240\346\203\263\347\237\245\351\201\223\347\232\204\n");


}




void  login_widget::do_chengji(QByteArray &data)
{
	/*获得成绩后开始 分析*/


	QSettings set("kebiao", "set");


	set.setValue(("xuehao"), ui->lineEdit_2->text());

	if (setCenter::is_rem)
	{
		set.setValue(("mima"), ui->lineEdit_3->text());

	}
	else
	{

		set.setValue(("mima"), "");
	}


	QString str = QString::fromLocal8Bit(data.data());


	int x;
	x = str.indexOf("mid_box");
	str = str.mid(x, -1);

	x = str.indexOf("<tr>") - 1;
	str = str.mid(x, -1);

	x = str.lastIndexOf("</table>");
	str = str.mid(0, x);

	int y;


	QString info = str.mid(0, str.indexOf("</table>"));
	str.remove(info);
	str.remove("</table>");

	info.remove("\t");

	info.remove("<td>");
	info.remove("</td>");
	info.remove("</tr>");

	info.remove("<tr>");

	info = info.mid(info.indexOf(">") + 1, -1);

	//<td colspan = "2">

	info.remove(info.indexOf("<"), info.indexOf(">") - info.indexOf("<") + 1);
	//	info.remove("\n");
	info.remove("\t");

	/*提示信息*/

	QMessageBox::warning(this, char_tixing, info);


	str = str.mid(str.indexOf("</tr>") + 5, -1);
	/*开始获取每一行*/
	QString row[20];
	int count = 0;


	str.remove(" class=");
	str.remove('"');
	str.remove("alt");


	while (str.lastIndexOf("</tr>") > 0)
	{
		x = str.indexOf("<tr>");
		y = str.indexOf("</tr>");
		row[count] = str.mid(x, y - x + 5);
		str = str.mid(y + 5, -1);

		++count;
	}

	/*	提取每行完成  开始分析数据*/


	for (int xx = 0; xx < count; xx++)
	{
		row[xx].remove("&nbsp;");

		row[xx].remove("<tr>");
		row[xx].remove("</tr>");
		/*去年份*/
		x = row[xx].indexOf("</td>");
		row[xx] = row[xx].mid(x + 5, row[xx].size() - x - 5);

		/*学期*/
		x = row[xx].indexOf("</td>");
		row[xx] = row[xx].mid(x + 5, row[xx].size() - x - 5);

		/*课程代号*/
		x = row[xx].indexOf("</td>");
		row[xx] = row[xx].mid(x + 5, -1);


		/*名字*/
		x = row[xx].indexOf("</td>");
		dataTable.dj_data[xx].cj_name = row[xx].mid(4, x - 4);
		row[xx] = row[xx].mid(x + 5, -1);
		//dataTable.dj_data[xx].cj_name.remove("<td>");


		/*性质*/
		x = row[xx].indexOf("</td>");
		dataTable.dj_data[xx].cj_pro = row[xx].mid(4, x - 4);
		row[xx] = row[xx].mid(x + 5, -1);

		/*归属*/
		x = row[xx].indexOf("</td>");
		row[xx] = row[xx].mid(x + 5, -1);

		/*学分*/
		x = row[xx].indexOf("</td>");
		dataTable.dj_data[xx].cj_xuefen = row[xx].mid(4, x - 4);
		row[xx] = row[xx].mid(x + 5, -1);

		/*平时成绩*/
		x = row[xx].indexOf("</td>");
		dataTable.dj_data[xx].cj_pingshi = row[xx].mid(4, x - 4);
		row[xx] = row[xx].mid(x + 5, -1);

		/*期中*/
		x = row[xx].indexOf("</td>");
		row[xx] = row[xx].mid(x + 5, -1);

		/*期末成绩*/
		x = row[xx].indexOf("</td>");
		dataTable.dj_data[xx].cj_qimo = row[xx].mid(4, x - 4);
		row[xx] = row[xx].mid(x + 5, -1);


		/*实验成绩*/
		x = row[xx].indexOf("</td>");
		row[xx] = row[xx].mid(x + 5, -1);

		/*期末成绩*/
		x = row[xx].indexOf("</td>");
		dataTable.dj_data[xx].cj_chenji = row[xx].mid(4, x - 4);
		row[xx] = row[xx].mid(x + 5, -1);

		//	fil.write(dataTable.dj_data[xx].cj_chenji.toStdString().c_str());


	}


	/*显示*/
	new cj_all_widget(p, count);
	slot_close();



}






void  login_widget::exec()
{

	/*ui->lineEdit->setText("");
	ui->lineEdit_2->setText("");
	ui->lineEdit_3->setText("");
	*/
	ui->label->setVisible(false);

	QSettings set("kebiao", "set");

	ui->lineEdit_2->setText(set.value("xuehao").toString());

	if (setCenter::is_rem)
	{
		ui->lineEdit_3->setText(set.value("mima").toString());

	}
	else
	{
		ui->lineEdit_3->setText("");

	}


	if (is_kebiao)
	{
		/*课表*/
		ui->label_5->setText("\344\273\216\346\225\231\345\212\241\347\263\273\347\273\237\345\257\274\345\205\245\350\257\276\347\250\213\350\241\250");

		ui->pushButton_4->setVisible(false);

	}
	else
	{
		/*成绩*/
		ui->label_5->setText("\344\273\216\346\225\231\345\212\241\347\263\273\347\273\237\346\237\245\350\257\242\346\210\220\347\273\251");
		ui->pushButton_4->setVisible(true);

	}

	QNetworkRequest request;
	request.setUrl(homepageUrl);
	request.setRawHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.3; WOW64; Trident/8.0)");
	request.setRawHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
	request.setRawHeader("Accept-Encoding", "gzip, deflate");
	request.setRawHeader("Accept-Language", "zh-CN,zh;q=0.8");
	request.setRawHeader("Cache-Control", "max-age=0");
	request.setRawHeader("Connection", "Keep-Alive");

	manager->get(request);

	ui->pushButton->setVisible(false);

	setStart();/*超时10秒*/

	this->show();

	setShow();


}






void login_widget::FixScreen()
{

	PublicFunc::resetGrid(ui->pushButton);

	PublicFunc::resetGrid(ui->pushButton_2);

	PublicFunc::resetGrid(ui->lineEdit);

	PublicFunc::resetGrid(ui->lineEdit_2);

	PublicFunc::resetGrid(ui->lineEdit_3);

	PublicFunc::resetGrid(ui->label);

	PublicFunc::resetGrid(ui->label_2);

	PublicFunc::resetGrid(ui->label_3);

	PublicFunc::resetGrid(ui->label_4);

	PublicFunc::resetGrid(ui->label_5);
	PublicFunc::resetGrid(ui->pushButton_4);

	PublicFunc::resetGrid(ui->pushButton_3);

	PublicFunc::resetGrid(ui->label_6);
	PublicFunc::resetGrid(ui->label_7);


}


////////////////////////////////



set_widget::set_widget(QWidget *parent) ://QWidget(parent),
ui(new Ui::set_widget)
{

	this->p = (MainWindow*)p;
	ui->setupUi(this);
	p = (MainWindow*)parent;

#ifndef Q_OS_WIN32
	FixScreen();
#endif

	connect(ui->pushButton_3, SIGNAL(clicked()), this, SLOT(slot_about()));
	connect(ui->pushButton_4, SIGNAL(clicked()), this, SLOT(slot_close()));
	connect(ui->pushButton_5, SIGNAL(clicked()), this, SLOT(slot_info()));
	connect(ui->pushButton_6, SIGNAL(clicked()), this, SLOT(slot_modify()));
	connect(ui->pushButton_7, SIGNAL(clicked()), this, SLOT(slot_is_show_all()));
	connect(ui->pushButton_8, SIGNAL(clicked()), this, SLOT(slot_vis_guanwang()));
	connect(ui->pushButton_9, SIGNAL(clicked()), this, SLOT(slot_check_for_update()));
	connect(ui->pushButton_10, SIGNAL(clicked()), this, SLOT(slot_cj()));

	connect(ui->pushButton_11, SIGNAL(clicked()), this, SLOT(slot_cont_me()));
	connect(ui->pushButton_12, SIGNAL(clicked()), this, SLOT(slot_new()));

	connect(ui->pushButton_13, SIGNAL(clicked()), this, SLOT(slot_is_rem()));
	connect(ui->pushButton_14, SIGNAL(clicked()), this, SLOT(slot_bot()));
	connect(ui->pushButton_15, SIGNAL(clicked()), this, SLOT(slot_cet()));

	ui->lineEdit->setValidator(new QIntValidator(1, 25, this));

	ui->lineEdit->setText(QVariant(setCenter::current_week).toString());

	if (setCenter::is_rem == true)
	{
		ui->pushButton_13->setText("\345\274\200");
	}
	else
	{

		ui->pushButton_13->setText("\345\205\263");
	}


	if (setCenter::is_show_all == true)
	{
		ui->pushButton_7->setText("\345\274\200");
	}
	else
	{

		ui->pushButton_7->setText("\345\205\263");
	}


}



void set_widget::slot_about()
{
	QMessageBox::warning(this, "\345\205\263\344\272\216", "\nKK\350\257\276\350\241\250(\347\220\206\345\267\245\344\270\223\347\211\210)\npower by hk @2015");

}


void set_widget::slot_modify()/**/
{
	setCenter::current_week = QVariant(ui->lineEdit->text()).toInt();
	setCenter::save();

	p->slot_curr();
	setCenter::saveCurrentDate();

	QMessageBox::warning(this, char_tixing, char_set_succ);


}




void set_widget::slot_cj()
{

	is_kebiao = false;
	p->login_widget_ref->exec();

}



void  set_widget::slot_is_rem()
{
	setCenter::is_rem = !setCenter::is_rem;

	if (setCenter::is_rem)
	{
		ui->pushButton_13->setText("\345\274\200");
	}
	else
	{
		ui->pushButton_13->setText("\345\205\263");
	}

	setCenter::save();

	QSettings set("kebiao", "set");


	if (!setCenter::is_rem)
	{
		set.setValue("mima", "");

	}

	QMessageBox::warning(this, char_tixing, char_set_succ);


}



void set_widget::slot_new()
{
	p->slot_new();

}



void set_widget::slot_bot()
{
	(new bot_widget(this))->show();
}



void set_widget::slot_cet()
{
	(new cet_widget(this))->show();
}



void set_widget::slot_cont_me()
{
	QDesktopServices::openUrl(QUrl("http://wpa.qq.com/msgrd?v=3&uin=771911064&site=qq&menu=yes"));
}


void  set_widget::slot_check_for_update()
{


}




void  set_widget::slot_info()
{
	QSettings set("kebiao", "1");
	QMessageBox::warning(this, "\350\257\276\350\241\250\344\277\241\346\201\257", set.value("info").toString());/*课表信息*/

}



void set_widget::slot_close()
{

	delete ui;
	delete this;

}


void  set_widget::slot_vis_guanwang()
{
	QDesktopServices::openUrl(QUrl("http://www.dreamyouxi.com/"));

}


void  set_widget::slot_is_show_all()
{
	setCenter::is_show_all = !setCenter::is_show_all;

	if (setCenter::is_show_all == true)
	{
		ui->pushButton_7->setText("\345\274\200");
	}
	else
	{
		ui->pushButton_7->setText("\345\205\263");
	}

	setCenter::save();
	p->slot_curr();

	QMessageBox::warning(this, char_tixing, char_set_succ);


}


void set_widget::FixScreen()
{

	PublicFunc::resetGrid(ui->pushButton_3);

	PublicFunc::resetGrid(ui->pushButton_4);
	PublicFunc::resetGrid(ui->pushButton_5);
	PublicFunc::resetGrid(ui->pushButton_6);
	PublicFunc::resetGrid(ui->pushButton_7);

	PublicFunc::resetGrid(ui->pushButton_8);

	PublicFunc::resetGrid(ui->pushButton_9);

	PublicFunc::resetGrid(ui->label);

	PublicFunc::resetGrid(ui->label_2);

	PublicFunc::resetGrid(ui->label_3);

	PublicFunc::resetGrid(ui->pushButton_11);
	PublicFunc::resetGrid(ui->pushButton_12);

	PublicFunc::resetGrid(ui->pushButton_14);
	PublicFunc::resetGrid(ui->pushButton_15);
	PublicFunc::resetGrid(ui->lineEdit);

	PublicFunc::resetGrid(ui->pushButton_10);

	PublicFunc::resetGrid(ui->pushButton_13);

	PublicFunc::resetGrid(ui->label_4);



}




